﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Numerics;

namespace ArgusLight.Fractals2D.ComplexFractalColoring
{
	public abstract class Coloring : ArgusLight.Fractals2D.Coloring
	{
		/// <summary>
		/// Type: <see cref="ComplexFractalParameter"/>
		/// </summary>
		public override FractalParameter FractalParameter
		{
			get
			{
				return this._fractalParameter;
			}
			protected set
			{
				this._fractalParameter = (ComplexFractalParameter)value;
			}
		}
		private ComplexFractalParameter _fractalParameter;
		protected ComplexFractalParameter fractalParameter { get { return (ComplexFractalParameter)this.FractalParameter; } }

		/// <summary>
		/// Type: <see cref="ColoringData"/>
		/// </summary>
		public override Fractals2D.ColoringData Data
		{
			get
			{
				return this._data;
			}
			protected set
			{
				if ((value is ColoringData) == true)
					this._data = (ColoringData)value;
			}
		}
		private ColoringData _data;
		protected ColoringData data { get { return (ColoringData)this.Data; } }

		public override Fractals2D.ColoringParameter Parameter
		{
			get
			{
				return this._parameter;
			}
			set
			{
				if (value is ColoringParameter)
					this._parameter = (ColoringParameter)value;
			}
		}
		private ColoringParameter _parameter;
		protected ColoringParameter parameter { get { return (ColoringParameter)this.Parameter; } }

		public Coloring()
			: base()
		{
			this._parameter = new ColoringParameter();
		}

		public override void Reset(FractalParameter fParameter)
		{
			base.Reset(fParameter);
			this.Data = new ColoringData(fParameter.PixelWidth, fParameter.PixelHeight);
		}

		public override Color GetColor(int x, int y)
		{
			if (this.data.iterations[x, y] >= this.fractalParameter.Iterations)
				return Colors.Black;
			if (this.data.iterations[x, y] < 1)
				return Colors.Black;
			return Colors.White;
		}

		public virtual int Iterations_get(int x, int y) { return this.data.iterations[x, y]; }
		public virtual void Iterations_set(int x, int y, int value) { this.data.iterations[x, y] = value; }
		public virtual Complex c_get(int x, int y) { return this.data.c[x, y]; }
		public virtual void c_set(int x, int y, Complex value) { this.data.c[x, y] = value; }
		public virtual Complex z_get(int x, int y) { return this.data.z[x, y]; }
		public virtual void z_set(int x, int y, Complex value) { this.data.z[x, y] = value; }
	}
}
